<?php
if (!isset($products))
    $products = Shop::getCartContent();

if (!isset($this->breadcrumbs) || ($this->breadcrumbs == array()))
    $this->breadcrumbs = array(
        Shop::t('Shop') => array('//shop/products/'),
        Shop::t('Shopping Cart'));
?>

<?php if ($products) { ?>
    <div class="sub-page">
        <h2>Payment</h2>

        <div class="all-product">

            <div class="contact">
                <div class="ct-title">Cart summary</div>
                <table class="tb-style">
                    <tr>
                        <th>No.</th>
                        <th>Picture</th>
                        <th>Item name</th>
                        <th>Quantity</th>
                        <th>Unit</th>
                        <th>Total</th>
                    </tr>
                    <?php
                    $i = 1;
                    $weightTotal = 0;
                    foreach ($products as $position => $product) {
                        if (@$model = Products::model()->findByPk($product['product_id'])) {
                            $variations = '';
                            if (isset($product['frame-included'])) {
                                // Check frame included
                                $variations = 1;
                            }
                            ?>
                            <tr>
                                <td align="center" valign="top" width="6%"><?php echo $i;?></td>
                                <td align="center" width="10%"><img src="<?php echo Yii::app()->request->baseUrl; ?>/data/upload/products/<?php echo isset($model->shopImages[0]) ? $model->shopImages[0]->filename : 'no_image.jpg'?>"
                                                                    width="50" height="50"></td>
                                <td><a href="product-detail.html"><?php echo $model['title'] ?></a></td>
                                <td align="center" valign="top" width="15%"><input readonly="true" style="width:60px" name=""
                                                                                   placeholder="<?php echo $product['amount']?>" type="text"></td>
                                <td align="left" valign="top" width="15%">
                                    <h3 rel="<?php echo Shop::priceFormat($model->getPrice(@$variations)); ?>" class="<?php echo 'price_'.$position;?>">$<?php echo Shop::priceFormat($model->getPrice(@$variations)); ?></h3></td>

                                <?php if($i == 1) {?>
                                <td width="15%" rowspan="<?php echo count($products)?>" align="center" valign="middle">
                                    <?php $totalPrice = Shop::getPriceTotal();?>
                                    <h2 rel="">$<?php echo $totalPrice ?></h2></td>
                                <?php }?>
                            </tr>
                            
                        <?php
                        } $i++;
                    }?>
                    <tr>
                    	<td colspan="5"><b>Shipping Price</b></td>
                        <td align="center">
                        	<?php $totalShipping = Shop::getShippingTotal();?>
                        	<h3>$<?php echo Shop::priceFormat($totalShipping);?></h3>
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="5"><h2>Total Payment</h2></td>
                        <td align="center"><h2>$<?php echo Shop::priceFormat($totalPrice + $totalShipping);?></h2></td>
                    </tr>
                </table>
            </div>
            <?php if(Shop::getPriceTotal() == 0):?>
            	<div style="clear:left">&nbsp;</div>
            	<div style="color:#008000">Pleasse contact with us to know detail about product</div>
            <?php else:?>
            <div class="contact">
                <div class="ct-title">Choose payment method</div>
                <div class="form-style marT20">
                    <p>
                        <span class="floatL" style="margin-top:10px"><input name="" type="radio" value=""
                                                                            checked></span>
                        <span class="floatL" style="margin-left:30px"><img
                                src="<?php echo Yii::app()->request->baseUrl; ?>/data/images/paypal_logo.png"
                                width="123" height="43"></span>
                    </p>

                    <p style="margin:20px 0">
                        PayPal is the safer, easier way to make an online payment either with your existing PayPal
                        account or a credit/debit card. Visa, Mastercard and American Express are accepted.
                    </p>

                    <p><img src="<?php echo Yii::app()->request->baseUrl; ?>/data/images/cards_default.gif" width="238"
                            height="32"></p>

                </div>
            </div>
            <div>
                <a class="red-button marT20" href="/shop/order/payment">Buy now</a>
            </div>
            <?php endif;?>
        </div>

    </div>
<?php
} else {
    echo Shop::t('Your shopping cart is empty');
}?>